import React, { Component } from 'react';
import { Collapse } from 'antd';

const fake = {
  "data": [
    {
      "article": "{'title': 'web\u6570\u636e', 'content': 'sad\u54c7'}", 
      "classify": "web", 
      "classify_id": "2", 
      "userl_id": "2"
    }, 
    {
      "article": "{'title': 'python\u20142', 'content': '\u6765\u81ea\u7528\u6237\u4e8c'}", 
      "classify": "python", 
      "classify_id": "3", 
      "userl_id": "2"
    }, 
    {
      "article": "{'title': 'python\u201232', 'content': '\u6765\u81ea\u7528\u6237\u4e8c'}", 
      "classify": "python", 
      "classify_id": "3", 
      "userl_id": "2"
    },
  ]
}

const Panel = Collapse.Panel;
const fakedata = fake.data;
const fakeList = [];
const result = [];
function list(fakedata) {
  for(var i=0; i<fakedata.length; i++){
    fakeList.push(fakedata[i].classify);
  }
}

function unique(fakeList){
  for(var i=0;i<fakeList.length;i++){
      if(result.indexOf(fakeList[i])==-1){
          result.push(fakeList[i])
      }
  }
  return result;
}

list(fakedata);
unique(fakeList);

class ClassifyList extends Component {
  constructor(props){
    super(props);
    this.state = {

    }
  }


  render(){
    return(
      <Collapse defaultActiveKey={['1']}>
        {result.map((item, index) => {
          return (
            <Panel header={item} key={index}>
              <p>123</p>
            </Panel>
          )
        })}
      </Collapse>
    )
  }
}

export default ClassifyList;